#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/time.h>

#define SERVER_IP "127.0.0.1"
#define PORT 9999
#define BUF_SIZE 1024

int main() {
    int client_socket;
    struct sockaddr_in server_addr;
    char buf[BUF_SIZE] = {0};

    client_socket = socket(PF_INET, SOCK_STREAM, 0);
    if(client_socket == -1) {
        perror("socket()");
        exit(1);
    }

    memset(&server_addr, 0, sizeof(server_addr));
    server_addr.sin_family = AF_INET;
    server_addr.sin_addr.s_addr = inet_addr(SERVER_IP);
    server_addr.sin_port = htons(PORT);

    if(connect(client_socket, (struct sockaddr*)&server_addr, sizeof(server_addr)) == -1) {
        perror("connect()");
        exit(1);
    }

    for(int i = 0; i < 700; i++) {
        send(client_socket, buf, BUF_SIZE, 0);
        usleep(1000 * 2);
        printf("Sent packet %d\n", i + 1);
    }

    close(client_socket);
    return 0;
}
